package cn.winwintech.Incense.client.request;

import javax.validation.constraints.NotNull;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.web.multipart.MultipartFile;

public class OperationReq {
	@NotNull(message = "{operation.json.null}")
	private String operation;

	private String token;

	private MultipartFile photo1;

	private MultipartFile photo2;

	private MultipartFile photo3;

	private MultipartFile photo4;

	public MultipartFile getPhoto1() {
		return photo1;
	}

	public void setPhoto1(MultipartFile photo1) {
		this.photo1 = photo1;
	}

	public MultipartFile getPhoto2() {
		return photo2;
	}

	public void setPhoto2(MultipartFile photo2) {
		this.photo2 = photo2;
	}

	public MultipartFile getPhoto4() {
		return photo4;
	}

	public void setPhoto4(MultipartFile photo4) {
		this.photo4 = photo4;
	}

	public MultipartFile getPhoto3() {
		return photo3;
	}

	public void setPhoto3(MultipartFile photo3) {
		this.photo3 = photo3;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public static class OperationBean {
		private String treeId;
		// 结香 1 管理2 采香 3
		private int type;
		private long createdAt;
		private Double latitude;
		private Double longitude;
		private int id;
		private int treeType;
		private String subtype;
		// 结香方法（预留） 采香方法（整株/截取）
		private String method;
		// 备注
		private String comment;
		// 天气
		private String weather;
		// 温度
		private String temperature;
		// 湿度
		private String humidity;
		// 风向
		private String wind;
		// 基径
		private String trLowDiameter;
		// 胸径
		private String trHightDiameter;
		// 树高
		private String trHeight;
		// 冠幅
		private String trCoverArea;

		public int getType() {
			return type;
		}

		public void setType(int type) {
			this.type = type;
		}

		public String getSubtype() {
			return subtype;
		}

		public void setSubtype(String subtype) {
			this.subtype = subtype;
		}

		public String getMethod() {
			return method;
		}

		public void setMethod(String method) {
			this.method = method;
		}

		public String getComment() {
			return comment;
		}

		public void setComment(String comment) {
			this.comment = comment;
		}

		public String getWeather() {
			return weather;
		}

		public void setWeather(String weather) {
			this.weather = weather;
		}

		public String getTemperature() {
			return temperature;
		}

		public void setTemperature(String temperature) {
			this.temperature = temperature;
		}

		public String getHumidity() {
			return humidity;
		}

		public void setHumidity(String humidity) {
			this.humidity = humidity;
		}

		public String getWind() {
			return wind;
		}

		public void setWind(String wind) {
			this.wind = wind;
		}

		public String getTrLowDiameter() {
			return trLowDiameter;
		}

		public void setTrLowDiameter(String trLowDiameter) {
			this.trLowDiameter = trLowDiameter;
		}

		public String getTrHightDiameter() {
			return trHightDiameter;
		}

		public void setTrHightDiameter(String trHightDiameter) {
			this.trHightDiameter = trHightDiameter;
		}

		public int getTreeType() {
			return treeType;
		}

		public void setTreeType(int treeType) {
			this.treeType = treeType;
		}

		public String getTreeId() {
			return treeId;
		}

		public void setTreeId(String treeId) {
			this.treeId = treeId;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}

		public long getCreatedAt() {
			return createdAt;
		}

		public void setCreatedAt(long createdAt) {
			this.createdAt = createdAt;
		}

		public String getTrHeight() {
			return trHeight;
		}

		public Double getLatitude() {
			return latitude;
		}

		public void setLatitude(Double latitude) {
			this.latitude = latitude;
		}

		public Double getLongitude() {
			return longitude;
		}

		public void setLongitude(Double longitude) {
			this.longitude = longitude;
		}

		public void setTrHeight(String trHeight) {
			this.trHeight = trHeight;
		}

		public String getTrCoverArea() {
			return trCoverArea;
		}

		public void setTrCoverArea(String trCoverArea) {
			this.trCoverArea = trCoverArea;
		}

		@Override
		public String toString() {
			return "OperationBean [treeId=" + treeId + ", type=" + type + ", createdAt=" + createdAt + ", id=" + id
					+ ", treeType=" + treeType + ", subtype=" + subtype + ", method=" + method + ", comment=" + comment
					+ ", weather=" + weather + ", temperature=" + temperature + ", humidity=" + humidity + ", wind="
					+ wind + ", trLowDiameter=" + trLowDiameter + ", trHightDiameter=" + trHightDiameter + ", trHeight="
					+ trHeight + ", trCoverArea=" + trCoverArea + "]";
		}

	}

	public OperationBean toObject() throws Exception {
		// Gson gson = new Gson();
		// OperationBean fromJson = gson.fromJson(operation,
		// OperationBean.class);
		// System.out.println(fromJson.comment);
		// return fromJson;
		ObjectMapper mapper = new ObjectMapper();
		System.out.println(operation);
		OperationBean fromJson = mapper.readValue(operation, OperationBean.class);
		return fromJson;

	}

}
